{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fa08a850-977b-45e3-b984-578b363a80a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dotenv:  E:\\work\\code\\ai\\.env\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from openai import OpenAI\n",
    "from dotenv import load_dotenv, find_dotenv\n",
    "\n",
    "def get_openai_key():\n",
    "    print(\"dotenv: \",find_dotenv())\n",
    "    _ = load_dotenv(find_dotenv())\n",
    "    # api_key = os.environ['OPENAI_API_KEY']\n",
    "    return OpenAI(\n",
    "        api_key = os.environ.get(\"ARK_API_KEY\"),\n",
    "    base_url = \"https://ark.cn-beijing.volces.com/api/v3\",)\n",
    "\n",
    "client = get_openai_key()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a0c4dcda-d27f-489c-bab3-de5b3b0fd110",
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_completion(prompt, model=\"ep-20250103110319-28xth\",temperature = 0):\n",
    "    \n",
    "    completion = client.chat.completions.create( \n",
    "    model = model,  # your model endpoint ID\n",
    "    messages = [\n",
    "        {\"role\": \"system\", \"content\": \"你是豆包，是由字节跳动开发的 AI 人工智能助手\"},\n",
    "        {\"role\": \"user\", \"content\": prompt},\n",
    "    ],\n",
    "    temperature=temperature\n",
    "    )\n",
    "    return completion.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fa8d9ebd-dcc9-4fbc-92f4-9da2c520f78d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hola, quiero ordenar una licuadora.\n"
     ]
    }
   ],
   "source": [
    "prompt= f\"\"\" \n",
    "    将以下中午翻译成西班牙语: \\\n",
    "    ```您好，我想订购一个搅拌机```\n",
    "    \"\"\" \n",
    "response = get_completion(prompt)\n",
    "print(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e32428cc-9139-4f0b-bb76-4bfd7455f645",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "这是法语。“Combien coûte le lampadaire?” 的意思是“这个路灯多少钱？”\n"
     ]
    }
   ],
   "source": [
    "prompt = f\"\"\"\n",
    "请告诉我以下文本是什么语种: \n",
    "```Combien coûte le lampadaire?```\n",
    "\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "338e44a3-2c9e-4523-b62f-7efe28b86ce4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "中文：我想要订购一个篮球。\n",
      "英文：I want to order a basketball. （原文就是英文）\n",
      "法语：Je veux commander un ballon de basket.\n",
      "西班牙语：Quiero ordenar un balón de baloncesto.\n"
     ]
    }
   ],
   "source": [
    "prompt = f\"\"\"\n",
    "请将以下文本分别翻译成中文、英文、法语和西班牙语: \n",
    "```I want to order a basketball.```\n",
    "\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8f04f5ab-11bf-42f6-8740-a8bebbfa144e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正式语气：您是否想要订购一个枕头呢？\n",
      "非正式语气：你要不要订一个枕头呀？\n"
     ]
    }
   ],
   "source": [
    "prompt = f\"\"\"\n",
    "请将以下文本翻译成中文，分别展示成正式与非正式两种语气: \n",
    "```Would you like to order a pillow?```\n",
    "\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "33c2ad9e-71e1-4884-b08d-3fd7d2939f50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 原始消息 (法语): La performance du système est plus lente que d'habitude.\n",
      "\n",
      "中文翻译: 系统的性能比平时慢。\n",
      "英文翻译：The system performance is slower than usual. \n",
      "=========================================\n",
      " 原始消息 (西班牙语): Mi monitor tiene píxeles que no se iluminan.\n",
      "\n",
      "中文翻译: 我的显示器有不亮的像素点。\n",
      "英文翻译：There are pixels on my monitor that don't light up. \n",
      "=========================================\n",
      " 原始消息 (意大利语): Il mio mouse non funziona\n",
      "\n",
      "中文翻译: 我的鼠标坏了。\n",
      "英文翻译：My mouse is not working. \n",
      "=========================================\n",
      " 原始消息 (波兰语): Mój klawisz Ctrl jest zepsuty\n",
      "\n",
      "中文翻译: 我的Ctrl键坏了\n",
      "英文翻译：My Ctrl key is broken \n",
      "=========================================\n",
      " 原始消息 (汉语): 我的屏幕在闪烁\n",
      "\n",
      "中文翻译: 我的屏幕在闪烁\n",
      "英文翻译：My screen is flickering. \n",
      "=========================================\n"
     ]
    }
   ],
   "source": [
    "user_messages = [\n",
    "  \"La performance du système est plus lente que d'habitude.\",  # System performance is slower than normal         \n",
    "  \"Mi monitor tiene píxeles que no se iluminan.\",              # My monitor has pixels that are not lighting\n",
    "  \"Il mio mouse non funziona\",                                 # My mouse is not working\n",
    "  \"Mój klawisz Ctrl jest zepsuty\",                             # My keyboard has a broken control key\n",
    "  \"我的屏幕在闪烁\"                                             # My screen is flashing\n",
    "]\n",
    "\n",
    "import time \n",
    "for issue in user_messages:\n",
    "    time.sleep(5)\n",
    "    prompt = f\"\"\" 告诉我以下文本是什么语种，直接输出语种，如法语，无需输出标点符号： ''' {issue}''' \"\"\" \n",
    "    lang = get_completion(prompt) \n",
    "    print(f\" 原始消息 ({lang}): {issue}\\n\" )\n",
    "\n",
    "    prompt = f\"\"\" \n",
    "    将以下消息分别翻译为英文和中文，并写成\n",
    "    中文翻译: xxx\n",
    "    英文翻译：yyyy\n",
    "    的格式：\n",
    "    ```{issue}```\n",
    "    \"\"\" \n",
    "    response = get_completion(prompt)\n",
    "    print(response, \"\\n=========================================\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "9e49a503-bdfc-42eb-98ee-5cd915e18a03",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**主题：关于部门显示器采购尺寸的询问**\n",
      "\n",
      "尊敬的[对方姓名]：\n",
      "\n",
      "您好！\n",
      "\n",
      "我是小羊。此前我们讨论过部门显示器采购的相关事宜，我想再次跟您确认一下，当时提到的要采购的显示器具体是多少寸的呢？\n",
      "\n",
      "感谢您的关注与支持，期待您的回复。\n",
      "\n",
      "祝工作顺利！\n",
      "\n",
      "[小羊姓名]\n",
      "\n",
      "[具体日期]\n"
     ]
    }
   ],
   "source": [
    "prompt = f\"\"\" \n",
    "    将以下文本翻译为商务信函的格式： \n",
    "    ```小老弟，我小羊，上回你说咱部门要采购的显示器是多少寸来着？```\n",
    "\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "cfcee2bc-5dfc-47ee-911a-3be9422e5cf1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "```html\n",
      "<!DOCTYPE html>\n",
      "<html>\n",
      "\n",
      "<body>\n",
      "\n",
      "  <table border=\"1\">\n",
      "    <tr>\n",
      "      <th colspan=\"2\">resturant employees</th>\n",
      "    </tr>\n",
      "    <tr>\n",
      "      <th>name</th>\n",
      "      <th>email</th>\n",
      "    </tr>\n",
      "    <tr>\n",
      "      <td>Shyam</td>\n",
      "      <td>shyamjaiswal@gmail.com</td>\n",
      "    </tr>\n",
      "    <tr>\n",
      "      <td>Bob</td>\n",
      "      <td>bob32@gmail.com</td>\n",
      "    </tr>\n",
      "    <tr>\n",
      "      <td>Jai</td>\n",
      "      <td>jai87@gmail.com</td>\n",
      "    </tr>\n",
      "  </table>\n",
      "\n",
      "</body>\n",
      "\n",
      "</html>\n",
      "```\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "```html\n",
       "<!DOCTYPE html>\n",
       "<html>\n",
       "\n",
       "<body>\n",
       "\n",
       "  <table border=\"1\">\n",
       "    <tr>\n",
       "      <th colspan=\"2\">resturant employees</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <th>email</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Shyam</td>\n",
       "      <td>shyamjaiswal@gmail.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Bob</td>\n",
       "      <td>bob32@gmail.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Jai</td>\n",
       "      <td>jai87@gmail.com</td>\n",
       "    </tr>\n",
       "  </table>\n",
       "\n",
       "</body>\n",
       "\n",
       "</html>\n",
       "```"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data_json = { \"resturant employees\" :[ \n",
    "    {\"name\":\"Shyam\", \"email\":\"shyamjaiswal@gmail.com\"},\n",
    "    {\"name\":\"Bob\", \"email\":\"bob32@gmail.com\"},\n",
    "    {\"name\":\"Jai\", \"email\":\"jai87@gmail.com\"}\n",
    "]}\n",
    "\n",
    "prompt = f\"\"\" \n",
    "将以下Python 字典从JSON转换为HTML表格并返回，保留标题和列名。\n",
    "不用返回转化过程。\n",
    "字典:\n",
    "```{data_json}```\n",
    "\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response)\n",
    "from IPython.display import display, Markdown, Latex, HTML, JSON\n",
    "display(HTML(response))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "d402172e-8209-4651-abf8-f09d18e4185f",
   "metadata": {},
   "outputs": [],
   "source": [
    "text = [ \n",
    "  \"The girl with the black and white puppies have a ball.\",  # The girl has a ball.\n",
    "  \"Yolanda has her notebook.\", # ok\n",
    "  \"Its going to be a long day. Does the car need it’s oil changed?\",  # Homonyms\n",
    "  \"Their goes my freedom. There going to bring they’re suitcases.\",  # Homonyms\n",
    "  \"Your going to need you’re notebook.\",  # Homonyms\n",
    "  \"That medicine effects my ability to sleep. Have you heard of the butterfly affect?\", # Homonyms\n",
    "  \"This phrase is to cherck chatGPT for spelling abilitty\"  # spelling\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "6aca8c97-d7da-4bf5-9cd0-44a131aca087",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 The girl with the black and white puppies has a ball.\n",
      "1 并未发现错误\n",
      "2 It's going to be a long day. Does the car need its oil changed?\n",
      "3 There goes my freedom. They're going to bring their suitcases.\n",
      "4 ```You're going to need your notebook.```\n",
      "5 That medicine affects my ability to sleep. Have you heard of the butterfly effect?\n",
      "6 ```This phrase is to check ChatGPT for spelling ability```\n"
     ]
    }
   ],
   "source": [
    "for i in range(len(text)):\n",
    "    time.sleep(4)\n",
    "    prompt = f\"\"\" 请校对并更正以下文本，并注意纠正文本保持原语种，无需输出原始文本。\n",
    "        如果没有发现任何错误，请说\"并未发现错误\"。\n",
    "    例如:\n",
    "    输入： I are happy. \n",
    "    输出: I am happy. \n",
    "    ```{text[i]}```\n",
    "    \"\"\" \n",
    "    response = get_completion(prompt)\n",
    "    print(i, response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "87d2e61c-186b-420a-b029-1618b29c54cc",
   "metadata": {},
   "outputs": [],
   "source": [
    "text = f\"\"\"\n",
    "Got this for my daughter for her birthday cuz she keeps taking \\\n",
    "mine from my room.  Yes, adults also like pandas too.  She takes \\\n",
    "it everywhere with her, and it's super soft and cute.  One of the \\\n",
    "ears is a bit lower than the other, and I don't think that was \\\n",
    "designed to be asymmetrical. It's a bit small for what I paid for it \\\n",
    "though. I think there might be other options that are bigger for \\\n",
    "the same price.  It arrived a day earlier than expected, so I got \\\n",
    "to play with it myself before I gave it to my daughter.\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "4ab03c1f-9724-4725-89bd-2429123e8f9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "校对及更正后的商品评论如下：\n",
      "\n",
      "```\n",
      "I got this for my daughter for her birthday because she keeps taking mine from my room. Adults like pandas too. She takes it everywhere with her, and it's super soft and cute. One of the ears is a bit lower than the other, and I don't think it was designed to be asymmetrical. However, it's a bit small considering what I paid for it. I think there might be other options of the same price but bigger in size. It arrived a day earlier than expected, so I got to play with it myself before giving it to my daughter.\n",
      "```\n",
      "\n",
      "主要修改说明：\n",
      "- “Got this”改为“I got this”，使句子结构更完整，明确动作的执行者。\n",
      "- “cuz”是口语化表达，正式写作中改为“because”。\n",
      "- “Yes, adults also like pandas too”表述较啰嗦，去掉“Yes”和“also” ，使表达更简洁。\n",
      "- “It's a bit small for what I paid for it though” 改为 “However, it's a bit small considering what I paid for it”，使句子逻辑更清晰，“however”用于引出转折关系，“considering”表示“考虑到”，更符合语境。\n",
      "- “I think there might be other options that are bigger for the same price”改为 “I think there might be other options of the same price but bigger in size”，使表达更通顺自然。\n",
      "- “gave it to”改为“giving it to”，“before”作为介词，后面接动名词形式。\n"
     ]
    }
   ],
   "source": [
    "prompt = f\"\"\" 校对并更正以下商品评论: ```{text}```\"\"\"\n",
    "response = get_completion(prompt)\n",
    "print(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "b27409cf-15b4-4901-aef4-540f53394875",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting redlines\n",
      "  Downloading redlines-0.5.1-py3-none-any.whl.metadata (4.7 kB)\n",
      "Collecting click<9.0.0,>=8.1.3 (from redlines)\n",
      "  Downloading click-8.1.8-py3-none-any.whl.metadata (2.3 kB)\n",
      "Collecting rich<14.0.0,>=13.3.5 (from redlines)\n",
      "  Downloading rich-13.9.4-py3-none-any.whl.metadata (18 kB)\n",
      "Collecting rich-click<2.0.0,>=1.6.1 (from redlines)\n",
      "  Downloading rich_click-1.8.5-py3-none-any.whl.metadata (7.9 kB)\n",
      "Requirement already satisfied: colorama in c:\\users\\79065\\.conda\\envs\\chatgpt\\lib\\site-packages (from click<9.0.0,>=8.1.3->redlines) (0.4.6)\n",
      "Collecting markdown-it-py>=2.2.0 (from rich<14.0.0,>=13.3.5->redlines)\n",
      "  Downloading markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)\n",
      "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\79065\\.conda\\envs\\chatgpt\\lib\\site-packages (from rich<14.0.0,>=13.3.5->redlines) (2.18.0)\n",
      "Requirement already satisfied: typing-extensions<5.0,>=4.0.0 in c:\\users\\79065\\.conda\\envs\\chatgpt\\lib\\site-packages (from rich<14.0.0,>=13.3.5->redlines) (4.12.2)\n",
      "Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich<14.0.0,>=13.3.5->redlines)\n",
      "  Downloading mdurl-0.1.2-py3-none-any.whl.metadata (1.6 kB)\n",
      "Downloading redlines-0.5.1-py3-none-any.whl (12 kB)\n",
      "Downloading click-8.1.8-py3-none-any.whl (98 kB)\n",
      "Downloading rich-13.9.4-py3-none-any.whl (242 kB)\n",
      "Downloading rich_click-1.8.5-py3-none-any.whl (35 kB)\n",
      "Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)\n",
      "Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)\n",
      "Installing collected packages: mdurl, click, markdown-it-py, rich, rich-click, redlines\n",
      "Successfully installed click-8.1.8 markdown-it-py-3.0.0 mdurl-0.1.2 redlines-0.5.1 rich-13.9.4 rich-click-1.8.5\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install redlines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "2940b3be-6a7d-4a80-b0d0-01dac28e62eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "<span style='color:red;font-weight:700;text-decoration:line-through;'>Got </span><span style='color:green;font-weight:700;'>校对及更正后的商品评论如下： </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>``` </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>I got </span>this for my daughter for her birthday <span style='color:red;font-weight:700;text-decoration:line-through;'>cuz </span><span style='color:green;font-weight:700;'>because </span>she keeps taking mine from my <span style='color:red;font-weight:700;text-decoration:line-through;'>room.  Yes, adults also </span><span style='color:green;font-weight:700;'>room. Adults </span>like pandas <span style='color:red;font-weight:700;text-decoration:line-through;'>too.  </span><span style='color:green;font-weight:700;'>too. </span>She takes it everywhere with her, and it's super soft and <span style='color:red;font-weight:700;text-decoration:line-through;'>cute.  </span><span style='color:green;font-weight:700;'>cute. </span>One of the ears is a bit lower than the other, and I don't think <span style='color:red;font-weight:700;text-decoration:line-through;'>that </span><span style='color:green;font-weight:700;'>it </span>was designed to be asymmetrical. <span style='color:red;font-weight:700;text-decoration:line-through;'>It's </span><span style='color:green;font-weight:700;'>However, it's </span>a bit small <span style='color:red;font-weight:700;text-decoration:line-through;'>for </span><span style='color:green;font-weight:700;'>considering </span>what I paid for <span style='color:red;font-weight:700;text-decoration:line-through;'>it though. </span><span style='color:green;font-weight:700;'>it. </span>I think there might be other options <span style='color:red;font-weight:700;text-decoration:line-through;'>that are bigger for </span><span style='color:green;font-weight:700;'>of </span>the same <span style='color:red;font-weight:700;text-decoration:line-through;'>price.  </span><span style='color:green;font-weight:700;'>price but bigger in size. </span>It arrived a day earlier than expected, so I got to play with it myself before <span style='color:red;font-weight:700;text-decoration:line-through;'>I gave </span><span style='color:green;font-weight:700;'>giving </span>it to my <span style='color:red;font-weight:700;text-decoration:line-through;'>daughter.</span><span style='color:green;font-weight:700;'>daughter. </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>``` </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>主要修改说明： </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “Got this”改为“I got this”，使句子结构更完整，明确动作的执行者。 </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “cuz”是口语化表达，正式写作中改为“because”。 </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “Yes, adults also like pandas too”表述较啰嗦，去掉“Yes”和“also” ，使表达更简洁。 </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “It's a bit small for what I paid for it though” 改为 “However, it's a bit small considering what I paid for it”，使句子逻辑更清晰，“however”用于引出转折关系，“considering”表示“考虑到”，更符合语境。 </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “I think there might be other options that are bigger for the same price”改为 “I think there might be other options of the same price but bigger in size”，使表达更通顺自然。 </span>\n",
       "\n",
       "<span style='color:green;font-weight:700;'>- “gave it to”改为“giving it to”，“before”作为介词，后面接动名词形式。</span>"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from redlines import Redlines\n",
    "from IPython.display import display, Markdown\n",
    "diff = Redlines(text,response)\n",
    "display(Markdown(diff.output_markdown))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "53b3b4c9-b374-48b6-a83c-feb077f648c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "**拼写和语法纠错后的文本**：\n",
       "Got this for my daughter for her birthday because she keeps taking mine from my room. Yes, adults like pandas too. She takes it everywhere with her, and it's super soft and cute. One of the ears is a bit lower than the other, and I don't think it was designed to be asymmetrical. It's a bit small for what I paid for it, though. I think there might be other options that are bigger for the same price. It arrived a day earlier than expected, so I got to play with it myself before I gave it to my daughter.\n",
       "\n",
       "**中文翻译**：\n",
       "我给女儿买这个当作生日礼物，因为她老是从我房间拿我的（类似物品）。没错，成年人也喜欢熊猫。她不管去哪儿都带着它，而且它超级柔软又可爱。它的一只耳朵比另一只稍低一点，我觉得这并不是设计成不对称的样子。不过就我花的钱来说，它有点小。我想可能有其他同样价格但尺寸更大的选择。它比预计时间提前一天到货了，所以在送给女儿之前，我自己还把玩了一番。\n",
       "\n",
       "【优点】 \n",
       "- 外观设计十分可爱，以熊猫为造型，深受孩子喜爱，女儿不管走到哪儿都带着它。\n",
       "- 材质超级柔软，触感极佳，给人很好的体验。\n",
       "- 物流速度快，比预期提前一天到货，让人惊喜。\n",
       " \n",
       "【缺点】 \n",
       "- 做工存在瑕疵，两只耳朵不对称，且不像是特意设计成不对称的效果。\n",
       "- 尺寸较小，与价格不太匹配，相同价格下可能有更大尺寸的其他选择。\n",
       "\n",
       "【总结】\n",
       "这款熊猫造型的产品整体比较可爱柔软，物流也很给力，但在做工和尺寸方面存在一些不足。如果对产品尺寸和做工要求较高的话，可能需要再斟酌一下；但如果更看重外观和物流速度，那它还是有一定吸引力的。"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "prompt = f\"\"\"\n",
    "针对以下三个反引号之间的英文评论文本，\n",
    "首先进行拼写和语法纠错，\n",
    "然后将其转化为中文， \n",
    "在将其转化成优质淘宝评论的风格，从各种角度出发，分别说明产品的优点与缺点，并进行总结。 \n",
    "润色一下描述，使评论更有吸引力。\n",
    "\n",
    "输出结果格式为： \n",
    "【优点】 xxx \n",
    "【缺点】 xxx \n",
    "【总结】xxx \n",
    "将结果输出成Markdown 格式。\n",
    "\n",
    "``` {text} ```\n",
    "\"\"\" \n",
    "response = get_completion(prompt)\n",
    "display(Markdown(response))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34f78d22-4b69-4563-a79f-f45cb84291a0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.21"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
